#include <iostream>

/**
 * 二维数组
 *
 * @Author ZhangGJ
 * @Date 2021/11/14 08:50
 */

template<class T>
bool make2dArray(T **&arr, int row, int column)
{
    try
    {
        arr = new T *[row];
        for (int i = 0; i < row; i++)
        {
            arr[i] = new int[column];
        }
        return true;
    }
    catch (std::bad_alloc &b)
    {
        return false;
    }
}

template<class T>
void delete2dArray(T **&arr, int row)
{
    for (int i = 0; i < row; i++)
    {
        delete[] arr[i];
    }
    delete[]arr;
    arr = nullptr;
}

int main()
{
    int **arr = new int *[3];
    make2dArray(arr, 3, 3);
    delete2dArray(arr, 3);
}
